%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/longAliases"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[44]<br />ᐳ: 8, 9, 14, 41, 43, 48, 10<br />2: PgSelect[7]<br />ᐳ: Access[45]<br />3: PgSelectRows[12]<br />ᐳ: 11, 13, 46, 47"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 13, 14, 47, 41<br /><br />ROOT PgSelectSingleᐸpersonᐳ[13]"):::bucket
    end
    Bucket0 --> Bucket1

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸpersonᐳ<br />More deps:<br />- Constantᐸ'sara.smith@email.com'ᐳ[48]"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgFromExpression43{{"PgFromExpression[43∈0] ➊"}}:::plan
    PgSelectInlineApply44["PgSelectInlineApply[44∈0] ➊"]:::plan
    Object10 & PgFromExpression43 & PgSelectInlineApply44 --> PgSelect7
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    List46{{"List[46∈0] ➊<br />ᐸ45,11ᐳ"}}:::plan
    Access45{{"Access[45∈0] ➊<br />ᐸ7.m.subqueryDetailsFor31ᐳ"}}:::plan
    First11{{"First[11∈0] ➊"}}:::plan
    Access45 & First11 --> List46
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    PgSelectRows12[["PgSelectRows[12∈0] ➊"]]:::plan
    PgSelectRows12 --> First11
    PgSelect7 --> PgSelectRows12
    PgSelectSingle13{{"PgSelectSingle[13∈0] ➊<br />ᐸpersonᐳ"}}:::plan
    First11 --> PgSelectSingle13
    PgSelect7 --> Access45
    Lambda47{{"Lambda[47∈0] ➊<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    List46 --> Lambda47
    List16{{"List[16∈1] ➊<br />ᐸ14,15ᐳ<br />More deps:<br />- Constantᐸ'people'ᐳ[14]"}}:::plan
    PgClassExpression15{{"PgClassExpression[15∈1] ➊<br />ᐸ__person__.”id”ᐳ"}}:::plan
    PgClassExpression15 --> List16
    PgSelectSingle13 --> PgClassExpression15
    Lambda17{{"Lambda[17∈1] ➊<br />ᐸbase64JSONEncodeᐳ"}}:::plan
    List16 --> Lambda17
    PgClassExpression18{{"PgClassExpression[18∈1] ➊<br />ᐸ__person__.”email”ᐳ"}}:::plan
    PgSelectSingle13 --> PgClassExpression18
    First32{{"First[32∈1] ➊"}}:::plan
    PgSelectRows33[["PgSelectRows[33∈1] ➊"]]:::plan
    PgSelectRows33 --> First32
    Lambda47 --> PgSelectRows33
    PgSelectSingle34{{"PgSelectSingle[34∈1] ➊<br />ᐸperson_friendsᐳ"}}:::plan
    First32 --> PgSelectSingle34
    PgClassExpression35{{"PgClassExpression[35∈1] ➊<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle34 --> PgClassExpression35

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,First11,PgSelectRows12,PgSelectSingle13,PgFromExpression43,PgSelectInlineApply44,Access45,List46,Lambda47 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PgClassExpression15,List16,Lambda17,PgClassExpression18,First32,PgSelectRows33,PgSelectSingle34,PgClassExpression35 bucket1

